package com.tengol.course.spring.boot.customer.starter.service.impl;

import com.tengol.course.spring.boot.customer.starter.config.HelloProperties;
import com.tengol.course.spring.boot.customer.starter.service.HelloService;

import java.util.Objects;

/**
 * HelloServiceImpl
 *
 * @author dongrui
 * @date 2020/05/17
 */
public class HelloServiceImpl implements HelloService {
    private HelloProperties helloProperties;

    public HelloServiceImpl(HelloProperties helloProperties) {
        this.helloProperties = helloProperties;
    }

    @Override
    public String sayHello(String name) {
        if (Objects.isNull(name)) {
            return null;
        }
        return helloProperties.getPrefix()
                .concat(" == hello ").concat(name).concat(" == ")
                .concat(helloProperties.getSuffix());
    }
}
